package com.yc.cinema;

import com.yc.cinema.bean.Cinema;
import com.yc.cinema.bean.User;
import com.yc.cinema.biz.ActorBiz;
import com.yc.cinema.biz.UserBiz;
import com.yc.cinema.dao.ActorDao;
import org.springframework.context.annotation.*;

import javax.annotation.PostConstruct;

@Configuration // 配置类 ==> beans.xml
@ComponentScan("com.yc.spring")
public class IocConfig {

    @Bean  // ==> <bean>
    @Primary
    User user(){
        User user = new User();
        user.setUsername("武松");
        return user;
    }

    @Bean("user1")  // ==> <bean>
    User user1(){
        User user = new User();
        user.setUsername("武松");
        return user;
    }

    @Bean("user3")  // ==> <bean>
    @Scope("prototype")
    User user3(){
        User user = new User();
        user.setUsername("武松");
        return user;
    }

    @Bean
    Cinema myCinema(){
        Cinema c = new Cinema();
        c.setName("红旗电影院");
        return c;
    }

    @Bean("myActorBiz")
    ActorBiz ActorBiz(){
        ActorBiz c = new ActorBiz();
        c.setAdao(new ActorDao());
        return c;
    }

}
